//
// Created by Langingsing on 2021/10/25.
//

#ifndef PROJ_COORDINATE_H
#define PROJ_COORDINATE_H

#include <iostream>

using namespace std;

template<typename number_t>
class Coord
{
public:
    Coord(number_t x = 0, number_t y = 0) : _x(x), _y(y)
    {}

    /// 获取x
    inline number_t x() const
    {
        return _x;
    }

    /// 获取y
    inline number_t y() const
    {
        return _y;
    }

    /// 设置x
    inline void x(int x)
    {
        _x = x;
    }

    /// 设置y
    inline void y(int y)
    {
        _y = y;
    }

    /// 坐标相加
    inline Coord operator+(Coord<number_t> const &c) const
    {
        return {_x + c._x, _y + c._y};
    }

    /// 输入坐标
    inline friend istream &operator>>(istream &in, Coord &c)
    {
        in >> c._x >> c._y;
        return in;
    }

    /// 输出坐标
    inline friend ostream &operator<<(ostream &out, Coord const &c)
    {
        out << '(' << c._x << ", " << c._y << ')';
        return out;
    }

    /// 坐标判等
    inline bool operator==(Coord const &c) const
    {
        return _x == c._x && _y == c._y;
    }

private:
    number_t _x; // x分量
    number_t _y; // y分量
};

#endif //PROJ_COORDINATE_H
